package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysDictDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysDict;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysDictDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    BasicColumn[] selectList = BasicColumn.columnList(dictId, dictTypeId, createTime, isEnable, dictName, dictCode, dictValue, sorts, parentId, dataLevel, memo);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysDict> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysDict> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysDictResult")
    Optional<TSysDict> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysDictResult", value = {
        @Result(column="dict_id", property="dictId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="dict_type_id", property="dictTypeId", jdbcType=JdbcType.CHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="is_enable", property="isEnable", jdbcType=JdbcType.BIT),
        @Result(column="dict_name", property="dictName", jdbcType=JdbcType.VARCHAR),
        @Result(column="dict_code", property="dictCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="dict_value", property="dictValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="sorts", property="sorts", jdbcType=JdbcType.SMALLINT),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.CHAR),
        @Result(column="data_level", property="dataLevel", jdbcType=JdbcType.INTEGER),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysDict> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysDict, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysDict, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int deleteByPrimaryKey(String dictId_) {
        return delete(c -> 
            c.where(dictId, isEqualTo(dictId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int insert(TSysDict record) {
        return MyBatis3Utils.insert(this::insert, record, TSysDict, c ->
            c.map(dictId).toProperty("dictId")
            .map(dictTypeId).toProperty("dictTypeId")
            .map(createTime).toProperty("createTime")
            .map(isEnable).toProperty("isEnable")
            .map(dictName).toProperty("dictName")
            .map(dictCode).toProperty("dictCode")
            .map(dictValue).toProperty("dictValue")
            .map(sorts).toProperty("sorts")
            .map(parentId).toProperty("parentId")
            .map(dataLevel).toProperty("dataLevel")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int insertMultiple(Collection<TSysDict> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysDict, c ->
            c.map(dictId).toProperty("dictId")
            .map(dictTypeId).toProperty("dictTypeId")
            .map(createTime).toProperty("createTime")
            .map(isEnable).toProperty("isEnable")
            .map(dictName).toProperty("dictName")
            .map(dictCode).toProperty("dictCode")
            .map(dictValue).toProperty("dictValue")
            .map(sorts).toProperty("sorts")
            .map(parentId).toProperty("parentId")
            .map(dataLevel).toProperty("dataLevel")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int insertSelective(TSysDict record) {
        return MyBatis3Utils.insert(this::insert, record, TSysDict, c ->
            c.map(dictId).toPropertyWhenPresent("dictId", record::getDictId)
            .map(dictTypeId).toPropertyWhenPresent("dictTypeId", record::getDictTypeId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(isEnable).toPropertyWhenPresent("isEnable", record::getIsEnable)
            .map(dictName).toPropertyWhenPresent("dictName", record::getDictName)
            .map(dictCode).toPropertyWhenPresent("dictCode", record::getDictCode)
            .map(dictValue).toPropertyWhenPresent("dictValue", record::getDictValue)
            .map(sorts).toPropertyWhenPresent("sorts", record::getSorts)
            .map(parentId).toPropertyWhenPresent("parentId", record::getParentId)
            .map(dataLevel).toPropertyWhenPresent("dataLevel", record::getDataLevel)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default Optional<TSysDict> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysDict, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default List<TSysDict> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysDict, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default List<TSysDict> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysDict, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default Optional<TSysDict> selectByPrimaryKey(String dictId_) {
        return selectOne(c ->
            c.where(dictId, isEqualTo(dictId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysDict, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysDict record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(dictId).equalTo(record::getDictId)
                .set(dictTypeId).equalTo(record::getDictTypeId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(isEnable).equalTo(record::getIsEnable)
                .set(dictName).equalTo(record::getDictName)
                .set(dictCode).equalTo(record::getDictCode)
                .set(dictValue).equalTo(record::getDictValue)
                .set(sorts).equalTo(record::getSorts)
                .set(parentId).equalTo(record::getParentId)
                .set(dataLevel).equalTo(record::getDataLevel)
                .set(memo).equalTo(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysDict record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(dictId).equalToWhenPresent(record::getDictId)
                .set(dictTypeId).equalToWhenPresent(record::getDictTypeId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(isEnable).equalToWhenPresent(record::getIsEnable)
                .set(dictName).equalToWhenPresent(record::getDictName)
                .set(dictCode).equalToWhenPresent(record::getDictCode)
                .set(dictValue).equalToWhenPresent(record::getDictValue)
                .set(sorts).equalToWhenPresent(record::getSorts)
                .set(parentId).equalToWhenPresent(record::getParentId)
                .set(dataLevel).equalToWhenPresent(record::getDataLevel)
                .set(memo).equalToWhenPresent(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int updateByPrimaryKey(TSysDict record) {
        return update(c ->
            c.set(dictTypeId).equalTo(record::getDictTypeId)
            .set(createTime).equalTo(record::getCreateTime)
            .set(isEnable).equalTo(record::getIsEnable)
            .set(dictName).equalTo(record::getDictName)
            .set(dictCode).equalTo(record::getDictCode)
            .set(dictValue).equalTo(record::getDictValue)
            .set(sorts).equalTo(record::getSorts)
            .set(parentId).equalTo(record::getParentId)
            .set(dataLevel).equalTo(record::getDataLevel)
            .set(memo).equalTo(record::getMemo)
            .where(dictId, isEqualTo(record::getDictId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict")
    default int updateByPrimaryKeySelective(TSysDict record) {
        return update(c ->
            c.set(dictTypeId).equalToWhenPresent(record::getDictTypeId)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(isEnable).equalToWhenPresent(record::getIsEnable)
            .set(dictName).equalToWhenPresent(record::getDictName)
            .set(dictCode).equalToWhenPresent(record::getDictCode)
            .set(dictValue).equalToWhenPresent(record::getDictValue)
            .set(sorts).equalToWhenPresent(record::getSorts)
            .set(parentId).equalToWhenPresent(record::getParentId)
            .set(dataLevel).equalToWhenPresent(record::getDataLevel)
            .set(memo).equalToWhenPresent(record::getMemo)
            .where(dictId, isEqualTo(record::getDictId))
        );
    }
}